package com.prompt.SensorHandle;

import android.content.Context;
import android.content.SharedPreferences;

import com.prompt.Effecter;
import com.prompt.GlobalState;
import com.prompt.utils.TimeUtil;


public class SensorBaseHandler {

	protected Context mContext;
	
	public SensorBaseHandler(Context mContext){
		this.mContext = mContext;
	}

	protected void vibrate(long[] pattern,int repeat){
		Effecter.getInstance().vibrate(pattern,repeat);
	}
	
	protected void playVoice(){
		Effecter.getInstance().playVoice();
	}

	protected boolean isNeedPro(){
		boolean result = true;
		if(GlobalState.getInstance().getIsALarm()){
			result = false;
		}else if(GlobalState.getInstance().isEnd(TimeUtil.getTodayStr())){
			result = false;
		}else if(isEndInPer()){
			result = false;
		}
		return result;
	}
	
	private boolean isEndInPer(){
		boolean result = false;
		SharedPreferences dateState = this.mContext.getSharedPreferences("dateState", 0); 
        String itemState = dateState.getString(TimeUtil.getTodayStr(), null);
        if(itemState != null && itemState.equals("1")){
			result = true;
		}
		return result;
	}
}
